home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-06 | 1.1 KB | 55 lines | [TEXT/MSET] |
- (*
- Our menList object, MenuList, is intended to be used when making new menus
- that are not resource based. Sending the id: message will obtain a number
- that is usable as a menu ID, that is, it will be a positive int, non-zero,
- and not already in use.
-
- *)
-
-
- :class menList super{ handle }
- int try
-
- private
-
- :m new:
- $ a1c @ put: super ;m
-
- :m count: ( -- n )
- new: self
- lock: super
- ptr: super w@ 6 / \ see IM I-346
- unlock: super ;m
-
- :m unique?: { mID \ result -- b }
- true -> result
- count: self 0
- lock: super
- ?DO
- ptr: super 6 + \ offset to start of 6 bytes of info for first menu
- I 6 * + \ offset to Menu handle for next menu
- @ \ the Menu handle
- @ w@ mID = IF false -> result leave THEN
- LOOP
- unlock: super
- result ;m
-
- :m getTry: ( -- n ) \ n will be a non-zero int greater than 256
- BEGIN
- 32000 random put: try
- get: try 1 256 within? not nip
- UNTIL get: try
- ;m
-
- public
-
- :m id: ( -- n ) \ Will return a number suitable for use as a menu ID.
- \ It will assure a unique number.
- BEGIN
- getTry: self unique?: self
- UNTIL get: try ;m
-
- ;class
-
- menList menuList
-